#coding=utf-8
from django.db import models

# Create your models here.
'''
来电记录
'''
class income(models.Model):
    phonenum=models.CharField(max_length=20,verbose_name='来电号码')
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    user=models.ForeignKey('users.users',verbose_name='业务员')
    conversition=models.TextField(verbose_name='会话记录')
    thetime=models.DateTimeField(auto_now_add=True,verbose_name='来电时间')
    class Meta:
        verbose_name = "来电记录"
        verbose_name_plural = "来电记录"
    
''' 
去电记录 
'''
class call(models.Model):
    phonenum=models.CharField(max_length=20,verbose_name='电话号码')
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    user=models.ForeignKey('users.users',verbose_name='业务员')
    conversition=models.TextField(verbose_name='会话记录')
    thetime=models.DateTimeField(auto_now_add=True,verbose_name='去电时间')
    call_mession=models.ForeignKey('call_mission',verbose_name='营销任务',null=True)
    class Meta:
        verbose_name = "电话回访记录"
        verbose_name_plural = "电话回访记录"

'''
短信发送记录
'''
class simsend(models.Model):
    mobile=models.CharField(max_length=20,verbose_name='手机号码')
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    user=models.ForeignKey('users.users',verbose_name='业务员')
    mynum=models.CharField(max_length=20,verbose_name='主机号码',null=True)
    conversition=models.CharField(max_length=250,verbose_name='短信内容')
    thetime=models.DateTimeField(auto_now_add=True,verbose_name='发送时间')
    sim_mession=models.ForeignKey('sim_mission',verbose_name='群发任务',null=True)
    class Meta:
        verbose_name = "短信发送记录"
        verbose_name_plural = "短信发送记录"
    
'''
邮件发送记录
'''
class emailsend(models.Model):
    email=models.EmailField(max_length=75,verbose_name='邮箱')
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    user=models.ForeignKey('users.users',verbose_name='业务员')
    mymail=models.EmailField(max_length=75,verbose_name='主机邮箱',null=True)
    content=models.TextField(verbose_name='邮件内容')
    thetime=models.DateTimeField(auto_now_add=True,verbose_name='发送时间')
    email_mession=models.ForeignKey('email_mission',verbose_name='群发任务',null=True)
    class Meta:
        verbose_name = "邮件发送记录"
        verbose_name_plural = "邮件发送记录"

'''
电话回访任务
'''
class call_mission(models.Model):
    phone=models.CharField(max_length=20,verbose_name='电话号码',null=True)
    mobile=models.CharField(max_length=20,verbose_name='手机号码',null=True)
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    purpose=models.CharField(max_length=250,verbose_name='回访目的')
    subject=models.ForeignKey('analyse.subject',verbose_name='调查问卷',null=True)
    btime=models.DateTimeField(auto_now_add=True,verbose_name='开始时间')
    etime=models.DateTimeField(auto_now_add=True,verbose_name='截止时间')
    maker=models.ForeignKey('users.users',verbose_name='计划人',db_column='maker',related_name='cmission_maker')
    actor=models.ForeignKey('users.users',verbose_name='执行者',db_column='actor',related_name='cmission_actor')
    status=models.CharField(max_length=1,choices=(('D', '执行中'), ('F', '已完成'),('A', '已放弃')),verbose_name='状态',null=True)
    def __unicode__(self):
        return u'%s给%s制定的计划-(%s-%s)'%(self.maker,self.actor,self.btime,self.etime)
    class Meta:
        verbose_name = "电话营销计划"
        verbose_name_plural = "电话营销计划"
    
'''
短信发送任务
'''
class sim_mission(models.Model):
    mobile=models.EmailField(max_length=75,verbose_name='邮箱')
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    content=models.CharField(max_length=250,verbose_name='短信内容')
    btime=models.DateTimeField(auto_now_add=True,verbose_name='开始时间')
    etime=models.DateTimeField(auto_now_add=True,verbose_name='截止时间')
    maker=models.ForeignKey('users.users',verbose_name='计划人',db_column='maker',related_name='smission_maker')
    actor=models.ForeignKey('users.users',verbose_name='执行者',db_column='actor',related_name='smission_actor')
    status=models.CharField(max_length=1,choices=(('D', '执行中'), ('F', '已完成'),('A', '已放弃')),verbose_name='状态',null=True)
    def __unicode__(self):
        return u'%s给%s制定的计划-(%s-%s)'%(self.maker,self.actor,self.btime,self.etime)
    class Meta:
        verbose_name = "短信群发计划"
        verbose_name_plural = "短信群发计划"
 
'''
邮件发送任务
'''
class email_mission(models.Model):
    email=models.CharField(max_length=20,verbose_name='手机号码')
    customer=models.ForeignKey('customer.info',verbose_name='客户',null=True)
    content=models.TextField(verbose_name='邮件内容')
    btime=models.DateTimeField(auto_now_add=True,verbose_name='开始时间')
    etime=models.DateTimeField(auto_now_add=True,verbose_name='截止时间')
    maker=models.ForeignKey('users.users',verbose_name='计划人',db_column='maker',related_name='emission_maker')
    actor=models.ForeignKey('users.users',verbose_name='执行者',db_column='actor',related_name='emission_actor')
    status=models.CharField(max_length=1,choices=(('D', '执行中'), ('F', '已完成'),('A', '已放弃')),verbose_name='状态',null=True)
    def __unicode__(self):
        return u'%s给%s制定的计划-(%s-%s)'%(self.maker,self.actor,self.btime,self.etime)
    class Meta:
        verbose_name = "邮件群发计划"
        verbose_name_plural = "邮件群发计划"
  